package com.tyut.musicdreamer.service.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tyut.musicdreamer.service.user.model.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 更新用户最后登录时间
     *
     * @param userId 用户ID
     * @return 影响行数
     */
    @Update("UPDATE md_user SET last_login_time = NOW() WHERE id = #{userId}")
    int updateLastLoginTime(@Param("userId") Long userId);

    /**
     * 更新用户头像
     *
     * @param userId 用户ID
     * @param avatarUrl 头像URL
     * @return 影响行数
     */
    @Update("UPDATE md_user SET avatar = #{avatarUrl} WHERE id = #{userId}")
    int updateAvatar(@Param("userId") Long userId, @Param("avatarUrl") String avatarUrl);
} 